package com.demo.dubborpc.consumer;

import com.demo.dubborpc.netty.NettyClient;
import com.demo.dubborpc.publicinterface.HelloService;

/**
 * @author gy
 * @date 2022/8/7
 */
public class ClientBootstrap {
    // 定义协议头
    public static final String protocolHead = "HelloService#hello#";

    public static void main(String[] args) throws Exception{

        // 创建一个消费者
        NettyClient consumer = new NettyClient();

        HelloService service = (HelloService) consumer.getBean(HelloService.class, protocolHead);

        for (;;) {
            Thread.sleep(2 * 1000);
            // 通过代理对象调用服务提供者的方法（服务）
            String response = service.hello("你好 dubbo~");
            System.out.println("服务器返回的响应 response = " + response);
        }

    }
}
